import http from '@/utils/http/axios'

enum Api {
    clientGetByDepartment = '/client/getByDepartment',
    ClientAll = '/client/all',
    ClientInfo = '/client/getclientinfo',
    ClientDelete = '/client/delete',
    ClientImport = '/client/clientImport',
    clientUpdate = '/client/update',
    strategySelect = '/strategy/select/',
    clientUser = '/clientuser/getByClient',
    clientUserSetTemplate = '/clientuser/setStrategy',
    clientTemplate = '/template/getbyid' , //  根据客户端id扫描客户端模板
    clientSetTemplateAll = '/client/setTemplateAll', // 根据模板id应用全局客户端模板
    clientSetTemplateByDept =  '/client/setTemplateByDept',  // departmentid tempId 根据部门id应用部门下客户端模板
    clientOnlineList = '/client/onlinelist',
    clientStatus = '/client/status',
    clientTurnStatus = '/client/turnstatus',
    getLicenseState = '/License/get',
    setLicenseState = '/License/set',
}

/**
 * @description: 根据部门id应用部门下客户端模板
 */
export function clientSetTemplateByDept(params: any) {
    return http.request({
        url: Api.clientSetTemplateByDept ,
        method: 'POST',
        params,
    }, {
        isShowMessage: true,
        successMessageText: '配置成功',
        errorMessageText: '配置失败'
    })
}

/**
 * @description: 根据模板id应用全局客户端模板
 */
export function clientSetTemplateAll(params: any) {
    return http.request({
        url: Api.clientSetTemplateAll ,
        method: 'POST',
        params,
    })
}

/**
 * @description: 根据客户端id扫描客户端模板
 */
export function clientTemplate(params: any) {
    return http.request({
        url: Api.clientTemplate ,
        method: 'POST',
        params,
    })
}

/**
 * @description: 修改用户
 */
export function clientUserSetTemplate(params: any) {
    return http.request({
        url: Api.clientUserSetTemplate ,
        method: 'POST',
        params,
    }, {
        isTransformRequestResult: false,
        isShowMessage: true,
        successMessageText: '修改成功',
        errorMessageText: '修改失败'
    })
}

/**
 * @description: 修改客户端
 */
export function clientUpdate(params: any) {
    return http.request({
        url: Api.clientUpdate ,
        method: 'POST',
        params,
    }, {
        isTransformRequestResult: false,
        isShowMessage: true,
        successMessageText: '修改成功',
        errorMessageText: '修改失败'
    })
}

/**
 * @description: 客户端用
 */
export function clientUser(params: any) {
    return http.request({
        url: Api.clientUser ,
        method: 'GET',
        params,
    }, {
        isTransformRequestResult: false
    })
}

/**
 * @description: 是否使用
 */
export function clientGetByDepartment(params: any) {
    return http.request({
        url: Api.clientGetByDepartment ,
        method: 'GET',
        params,
    }, {
        isTransformRequestResult: false
    })
}

/**
 * @description: 某客户端列表
 */
export function strategySelect(params: any, stype) {
    return http.request({
        url: Api.strategySelect + stype,
        method: 'POST',
        params,
    })
}

/**
 * @description: 获取客户端列表
 */
export function clientAll(params: any) {
    return http.request({
        url: Api.ClientAll,
        method: 'POST',
        params,
    })
}
/**
 * @description: 导入文件
 */
export function ClientImport(params: any) {
    return http.uploadFiles({
        url: Api.ClientImport,
        method: 'POST',
    }, params, {
        isTransformRequestResult: false,
        isShowMessage: true,
        successMessageText: '导入成功',
        errorMessageText: '导入失败'
    })
}

/**
 * @description: 删除终端
 */
export function ClientDelete(params: any) {
    return http.request({
        url: Api.ClientDelete ,
        method: 'POST',
        params,
    },{
        isShowMessage: true,
        successMessageText: '删除成功',
        errorMessageText: '删除失败'
    })
}

/**
 * @description: 获取客户端详情
 */
export function ClientInfo(params: any) {
    return http.request({
        url: Api.ClientInfo ,
        method: 'GET',
        params,
    })
}

/**
 * @description: 获取在线终端列表
 */
export function ClientOnlineList(){
    return http.request({
        url: Api.clientOnlineList,
        method: 'GET'
    })
}

/**
 * @description: 获取客户端运行状态
 */
export function ClientStatus(params: any){
    return http.request({
        url: Api.clientStatus,
        method: "POST",
        params,
    })
}

/**
 * @description: 改变客户端运行状态
 */
export function ClientTurnStatus(params: any){
    return http.request({
        url: Api.clientTurnStatus,
        method: "POST",
        params,
    },{
        isTransformRequestResult: false
    })
}

/**
 * @description: 获取客户端证书启用状态
 **/
export function GetLicenseState(params: any){
    return http.request({
        url: Api.getLicenseState,
        method: "POST",
        params,
    },{
        isTransformRequestResult: true
    })
}

/**
 * @description: 设置客户端证书启用状态
 **/
export function SetLicenseState(params: any){
    return http.request({
        url: Api.setLicenseState,
        method: "POST",
        params,
    },{
        isTransformRequestResult: false
    })
}
